import { useStore } from '@/store'

/**
 *
 * @param pageName 页面的名称
 * @param handleName 按钮的名称
 * @param verifyPermission 拼接而成用于查找是否有该权限
 * @returns 返回一个Boolean，用于v-if判断
 */
export function usePermission(pageName: string, handleName: string) {
  const store = useStore()
  const permissions = store.state.login.permissions
  const verifyPermission = `system:${pageName}:${handleName}`

  return !!permissions.find((item) => item === verifyPermission)
}
